import request from '@/axios'
import { SysApiDetailVo, SysApiEditQo, SysApiListVo, SysApiSearchQo } from './types'
import { BaseDeleteQo } from '@/base/api/BaseQo'
import { KeyLabelValueVo } from '@/base/api/KeyLabelValueVo'

export const sysApiPageApi = (data: SysApiSearchQo): Promise<IResponse<Array<SysApiListVo>>> => {
  return request.post({ url: '/sysApi/page.adw', data })
}

export const sysApiDetailApi = (id: number): Promise<IResponse<SysApiDetailVo>> => {
  const data = { id }
  return request.post({
    url: '/sysApi/detail.adw',
    data
  })
}

export const sysApiAddApi = (data: SysApiEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysApi/add.adw', data })
}

export const sysApiUpdateApi = (data: SysApiEditQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysApi/update.adw', data })
}

export const sysApiDeleteApi = (data: BaseDeleteQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysApi/delete.adw', data })
}

export const sysApiRefreshApiRoleApi = (): Promise<IResponse<any>> => {
  return request.post({ url: '/sysApi/refreshApiRole.adw'})
}

export const sysApiAutoBindApiMenuApi = (): Promise<IResponse<any>> => {
  return request.post({ url: '/sysApi/autoBindApiMenu.adw'})
}

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]
export const selectSysApiNameListApi = (
  data: SysApiSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysApi/selectNameList.adw', data })
}
export const selectSysApiUrlListApi = (
  data: SysApiSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysApi/selectUrlList.adw', data })
}
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
